﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
using System.Collections;


namespace PJ.Data.Inventory
{
    public abstract class InventoryItemOrderParamAXProvider<TDataInterface> 
        : EntityAXProvider<TDataInterface>, IInventoryItemOrderParamProvider<TDataInterface>
        where TDataInterface : class, IInventoryItemOrderParamData
    {
        protected InventoryItemOrderParamAXProvider(IInventoryItemOrderParamCache<TDataInterface> cache)
            : base(cache)
        {

        }

        protected override void CopyFromContainer(IEnumerator enumerator, TDataInterface data)
        {
            base.CopyFromContainer(enumerator, data);
            if (enumerator.MoveNext())
            {
                data.UnitId = ((string)enumerator.Current).Trim();
                if (enumerator.MoveNext())
                {
                    data.DefaultQuantity = (double)enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        data.MultipleQuantity = (double)enumerator.Current;
                        if (enumerator.MoveNext())
                        {
                            data.MinQuantity = (double)enumerator.Current;
                            if (enumerator.MoveNext())
                            {
                                data.MaxQuantity = (double)enumerator.Current;
                                return;
                            }
                        }
                    }
                }
            }
            throw new ArgumentException("Container size error", "enumerator");
        }

    }
}
